package cn.lu.joke.util;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

import cn.lu.joke.App;

public class SharePreferenceUtils {

    private static SharedPreferences mSp = App.get().getSharedPreferences("config", Context.MODE_PRIVATE);

    public static void saveUserHeadImageSignKey(long keyTime) {
        mSp.edit().putLong("head_img_key", keyTime).apply();
    }

    public static long getUserHeadImageSignKey() {
        return mSp.getLong("head_img_key", 0);
    }

    public static void saveLoginState() {
        mSp.edit().putLong("identify", App.getLoginUser().id)
                .putString("token", App.getUserToken()).apply();
    }

    public static long getUserIdentify() {
        return mSp.getLong("identify", 0);
    }

    public static String getUserToken() {
        return mSp.getString("token", null);
    }

    public static void saveSplashImageSignKey(long keyTime) {
        mSp.edit().putLong("splash_img_key", keyTime).apply();
    }

    public static long getSplashImageSignKey() {
        return mSp.getLong("splash_img_key", 0);
    }
}
